﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

/*
 * Puppet
 *
 *
 * 依赖：
 *
 *
 * ！不写重复代码！
 * @author TTun
 * @date 7/12/2017 5:16:56 PM
 */
namespace TTGameEngine {
public class SkillReadInfo : MonoBehaviour {

    public SkillConfigInfo[] infos;
    public Dictionary<uint, SkillConfigInfo> infoDict = new Dictionary<uint, SkillConfigInfo>();

    static SkillReadInfo instance;
    public static SkillReadInfo Instance {
        get {
            if(instance == null) {
                instance = GameObject.FindObjectOfType<SkillReadInfo>();
            }
            return instance;
        }
    }

    void Awake() {
        if(instance == null) {
            instance = this;
            RebuildSkillInfo();
        }
    }

    public void RebuildSkillInfo() {
        infoDict.Clear();
        for(int i = 0; i < infos.Length; i++) {
            infoDict.Add(infos[i].skillID, infos[i]);
        }
    }

    public SkillConfigInfo GetSkillInfo(uint id) {
        if(infoDict.ContainsKey(id)) {
            return infoDict[id];
        }
        return null;
    }
}
}